<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
<style>
.axis path,
.axis line{
    fill: none;
    stroke: black;
    shape-rendering: crispEdges;
}

.axis text {
    font-family: sans-serif;
    font-size: 11px;
}
</style>
<script src="https:d3js.org/d3.v6.min.js"></script>
</head>
<body>
  <script>
    //数据
    var dataset = [ 2.5 , 2.1 , 1.7 , 1.3 , 0.9 ];
    var svg = d3.select('body').append('svg')
	.attr('width',600)
	.attr('height',600)
	.attr('transform','translate('+300+','+300+')')
    

    //定义比例尺
    var linear = d3.scaleLinear()
	.domain([0,d3.max(dataset)])
	.range([0,250])

    var axis =d3.axisBottom()
     .scale(linear)      //指定比例尺
     //.orient("bottom")   //指定刻度的方向
     .ticks(7);          //指定刻度的数量

	 svg.selectAll('g').data(dataset)
	.join('g')
	.call(axis)
	.attr("class","axis")
  .attr("transform","translate(20,130)")
	
  </script>
</body>
</html>